package cn.yudao.transactionmq;


import org.apache.rocketmq.client.producer.LocalTransactionState;
import org.apache.rocketmq.client.producer.TransactionListener;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageExt;

public class TranListen implements TransactionListener {


    /**
    * @Title: executeLocalTransaction
    * @Description: 发送commit/ROLLBACK成功
    * @Author: Mr.Jia
    * @Version: 1.0
    * @Date:  2022/7/25 19:17
    * @Parameters:
    * @Return
    */
    @Override
    public LocalTransactionState executeLocalTransaction(Message message, Object o) {
        System.out.println("发送成功");
        return LocalTransactionState.COMMIT_MESSAGE;
    }

    /**
    * @Title: checkLocalTransaction
    * @Description: 发送commit/ROLLBACK失败
    * @Author: Mr.Jia
    * @Version: 1.0
    * @Date:  2022/7/25 19:18
    * @Parameters:
    * @Return
    */
    @Override
    public LocalTransactionState checkLocalTransaction(MessageExt messageExt) {
        System.out.println("发送失败");
        return LocalTransactionState.ROLLBACK_MESSAGE;
    }
}
